package com.uzai.console.web.wechatprivate;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.uzai.common.enums.WxqBlacklistTypeEnum;
import com.uzai.console.annotation.SystemLogType;
import com.uzai.console.dto.wechatprivate.wxq.wxgroupblacklist.blacklistprv.WxqBlacklistPrvIdDto;
import com.uzai.console.dto.wechatprivate.wxq.wxgroupblacklist.blacklistprv.WxqBlacklistPrvQuery;
import com.uzai.console.enums.OperationTypeEnum;
import com.uzai.console.enums.SystemModelEnum;
import com.uzai.console.service.wechatprivate.WxqBlacklistPrvService;
import com.uzai.console.vo.base.SelectKeyVo;
import com.uzai.console.vo.wechatprivate.wxq.wxgroupblacklist.blacklistprv.WxqBlacklistPrvVo;
import com.uzai.console.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * 社群私有黑名单
 * @author liuqi
 * @date 2021年08月16日 15:11
 */
@Api(value = "社群私有黑名单",tags = "个人微信|社群黑名单|社群私有黑名单")
@ApiSort(5)
@RestController
public class WxqBlacklistPrvController extends BaseController {
    private Logger logger = LoggerFactory.getLogger(WxqBlacklistPrvController.class);

    @Autowired
    private WxqBlacklistPrvService wxqBlacklistPrvService;

    @ApiOperation(value = "分页查询社群私有黑名单列表", notes = "分页查询社群私有黑名单列表", response = WxqBlacklistPrvVo.class)
    @ApiOperationSupport(order = 1)
    @PostMapping("/wxqBlacklistPrv/findWxqBlacklistPrvList")
    public Object findWxqBlacklistPrvList(@RequestBody WxqBlacklistPrvQuery wxqBlacklistPrvQuery){
        return wxqBlacklistPrvService.findWxqBlacklistPrvList(wxqBlacklistPrvQuery);
    }

    @SystemLogType(model = SystemModelEnum.WxqBlacklistPrv, type = OperationTypeEnum.DELETE)
    @ApiOperation(value = "移除社群私有黑名单", notes = "移除社群私有黑名单")
    @ApiOperationSupport(order = 4)
    @PostMapping("/wxqBlacklistPrv/deleteWxqBlacklistPrv")
    public Object deleteWxqBlacklistPrv(@RequestBody WxqBlacklistPrvIdDto wxqBlacklistPrvIdDto){
        wxqBlacklistPrvService.deleteWxqBlacklistPrv(wxqBlacklistPrvIdDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.WxqBlacklistPrv, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "共享至全网", notes = "共享至全网")
    @ApiOperationSupport(order = 5)
    @PostMapping("/wxqBlacklistPrv/shareWxqBlacklistPub")
    public Object shareWxqBlacklistPub(@RequestBody WxqBlacklistPrvIdDto wxqBlacklistPrvIdDto){
        wxqBlacklistPrvService.shareWxqBlacklistPub(wxqBlacklistPrvIdDto);
        return true;
    }

    @ApiOperation(value = "查询社群黑名单类型下拉选择框列表", notes = "查询社群黑名单类型下拉选择框列表")
    @ApiOperationSupport(order = 7)
    @PostMapping("/wxqBlacklistPrv/findWxqBlacklistTypeSelect")
    public Object findWxqBlacklistTypeSelect(){
        List<SelectKeyVo> selectIdVoList = new ArrayList<>();

        for (WxqBlacklistTypeEnum wxqBlacklistTypeEnum : WxqBlacklistTypeEnum.values()){
            SelectKeyVo selectKeyVo = new SelectKeyVo();
            selectKeyVo.setKey(String.valueOf(wxqBlacklistTypeEnum.getValue()));
            selectKeyVo.setValue(wxqBlacklistTypeEnum.getDesc());
            selectIdVoList.add(selectKeyVo);
        }
        return selectIdVoList;
    }

    @SystemLogType(model = SystemModelEnum.WxqBlacklistPrv, type = OperationTypeEnum.DELETE)
    @ApiOperation(value = "取消共享至全网", notes = "取消共享至全网")
    @ApiOperationSupport(order = 8)
    @PostMapping("/wxqBlacklistPrv/cancleWxqBlacklistPub")
    public Object cancleWxqBlacklistPub(@RequestBody WxqBlacklistPrvIdDto wxqBlacklistPrvIdDto){
        wxqBlacklistPrvService.cancelWxqBlacklistPub(wxqBlacklistPrvIdDto);
        return true;
    }

}
